package com.tz.util.weixinUtils.template;

import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.tz.util.weixinUtils.vo.AccessTokenUtil;
import com.tz.util.weixinUtils.vo.WeiXinUtil;

import net.sf.json.JSONObject;

public class WeixinMsgPushUtil {


	private static final Logger logger = LoggerFactory.getLogger(WeixinMsgPushUtil.class);
	
	private static String urlPrefix = "https://api.weixin.qq.com/cgi-bin/message/template/send?access_token=";
	
	//物流填写页
	private static String expressInputUrl = "http://www.6weiyi.com/jinlele/mall#/procreceivefor"+"ORDER_NO"+"with"+"ORDER_TYPE";
	//订单进度页
	private static String progressUrl = "http://www.6weiyi.com/jinlele/mall#/serviceProgress/"+"ORDER_TYPE"+"/"+"ORDER_NO";
	//订单进度详情页
	private static String progressDetailUrl = "http://www.6weiyi.com/jinlele/mall#/proctest/"+"ORDER_TYPE"+"/"+"ORDER_NO";
	//检验报告页
	private static String checkReportUrl = "http://www.6weiyi.com/jinlele/mall#/checkReportfor"+"ORDER_TYPE"+"with"+"ORDER_NO";
	//发货通知详情页
	private static String procCheckUrl = "http://www.6weiyi.com/jinlele/mall#/proccheck/"+"ORDER_TYPE"+"/"+"ORDER_NO";
	//维修费用通知详情页
	private static String repairFeeUrl = "http://www.6weiyi.com/jinlele/mall#/procfixprice/repair/"+"ORDER_NO";
	//放弃换款发货通知详情页
	private static String procPostUrl = "http://www.6weiyi.com/jinlele/mall#/procpost/"+"ORDER_TYPE"+"/"+"ORDER_NO";
	//不知道是什么页面
	//http://www.6weiyi.com/jinlele/mall#/orderdetailfor"+order.getOrderNo()+"with"+order.getOrderType()
	
	
	
	/**
	 * @description 付款成功通知，使用模块：维修，检测，翻新
	 * @param order
	 * @param openId
	 */
	public static void sendT1(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T1.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        if("001".equals(order.getSendWay())){
        	temp.setUrl(expressInputUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	first.setValue("您的".concat(order.getOrderTypeDesc()).concat("订单已付款成功，请尽快寄出您的宝贝！"));
        }else{
        	temp.setUrl(progressUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	first.setValue("您的".concat(order.getOrderTypeDesc()).concat("订单已付款成功，请尽快将您的宝贝送达门店！"));
        }
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(order.getStoreAddress());
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getStoreContactName());
        m.put("keyword2", keyword2);
        
        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword3", keyword3);
        
        TemplateData keyword4 = new TemplateData();
        keyword4.setColor("#000000");
        keyword4.setValue(order.getPrice());
        m.put("keyword4", keyword4);
        
        TemplateData keyword5 = new TemplateData();
        keyword5.setColor("#000000");
        keyword5.setValue(order.getOrderNo());
        m.put("keyword5", keyword5);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        if("001".equals(order.getSendWay())){
        	remark.setValue("宝贝寄出后，请正确填写快递单号以便核对您的订单！");
        }else{
        	remark.setValue("客服电话：400-8306-830");
        }
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	}

	/**
	 * 提交订单通知 ，使用模块：换款
	 * @param order
	 * @param openId
	 */
	public static void sendT2(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T2.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        if("001".equals(order.getSendWay())){
        	temp.setUrl(expressInputUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	first.setValue("您的".concat(order.getOrderTypeDesc()).concat("订单已提交成功，请尽快寄出您的宝贝！"));
        }else{
        	temp.setUrl(progressUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	first.setValue("您的".concat(order.getOrderTypeDesc()).concat("订单已提交成功，请尽快将您的宝贝送达门店！"));
        }
        
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(order.getStoreAddress());
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getStoreContactName());
        m.put("keyword2", keyword2);
        
        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword3", keyword3);
        
        TemplateData keyword4 = new TemplateData();
        keyword4.setColor("#000000");
        keyword4.setValue(order.getOrderNo());
        m.put("keyword4", keyword4);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        if("001".equals(order.getSendWay())){
        	remark.setValue("宝贝寄出后，请正确填写快递单号以便核对您的订单！");
        }else{
        	remark.setValue("客服电话：400-8306-830");
        }
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	}
	
	/**
	 * 检测报告通知，使用模块：换款，维修，检测，回收，翻新
	 * @param order
	 * @param openId
	 */
	public static void sendT3(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setUrl(checkReportUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T3.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("尊敬的六唯壹用户，您的宝贝贵金属检测已完成！查看检测报告请点击。");
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getOrderNo());
        m.put("keyword2", keyword2);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        if("004".equals(order.getOrderType()) || "005".equals(order.getOrderType())){
        	remark.setValue("如有疑问请联系客服：400-8306-830");
        }else{
        	remark.setValue("下一步将为您的宝贝进行".concat(order.getOrderTypeDesc()).concat("服务，敬请留意！"));
        }
        m.put("remark", remark);
    
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	
	}
	
	/**
	 * 提交订单通知 使用模块：回收
	 * @param order
	 * @param openId
	 */
	public static void sendT4(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T4.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        if("001".equals(order.getSendWay())){
        	temp.setUrl(expressInputUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	first.setValue("您的".concat(order.getOrderTypeDesc()).concat("订单已提交成功，请尽快寄出您的宝贝！"));
        }else{
        	temp.setUrl(progressUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	first.setValue("您的".concat(order.getOrderTypeDesc()).concat("订单已提交成功，请尽快将您的宝贝送达门店！"));
        }
        
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(order.getStoreAddress());
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getStoreContactName());
        m.put("keyword2", keyword2);
        
        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword3", keyword3);
        
        TemplateData keyword4 = new TemplateData();
        keyword4.setColor("#000000");
        keyword4.setValue(order.getPrice());
        m.put("keyword4", keyword4);
        
        TemplateData keyword5 = new TemplateData();
        keyword5.setColor("#000000");
        keyword5.setValue(order.getOrderNo());
        m.put("keyword5", keyword5);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        if("001".equals(order.getSendWay())){
        	remark.setValue("宝贝寄出后，请正确填写快递单号以便核对您的订单！");
        }else{
        	remark.setValue("客服电话：400-8306-830");
        }
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	}
	
	/**
	 * 取货通知 使用模块：换款、回收
	 * @param order
	 * @param openId
	 */
	public static void sendT5(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T5.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        if("005".equals(order.getOrderType())){//换款
        	temp.setUrl(progressUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	if(order.isCustomerConfirm()){
        		first.setValue("您选兑换的新珠宝已准备好，请尽快到门店取走！");
        	}else{
        		first.setValue("您已确认放弃珠宝换款，请尽快到门店取回您的产品！");
        	}
        }else if("004".equals(order.getOrderType())){//回收
        	temp.setUrl(procCheckUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	first.setValue("您已确认放弃产品回收，请尽快到门店取回您的产品！");
        }
        
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(order.getStoreAddress());
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getStoreContactName());
        m.put("keyword2", keyword2);
        
        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword3", keyword3);
        
        TemplateData keyword4 = new TemplateData();
        keyword4.setColor("#000000");
        keyword4.setValue(order.getOrderNo());
        m.put("keyword4", keyword4);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("请核对信息，如有疑问请联系客服：400-8306-830");
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	
	}
	
	/**
	 * 维修/翻新/检测 商家发货通知
	 * @param order
	 * @param openId
	 */
	public static void sendT6(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setUrl(procCheckUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T6.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("您的宝贝".concat(order.getOrderTypeDesc()).concat("服务已完成，宝贝已交付顺丰快递，请注意查收！"));
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(order.getExpressCode());
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getReceiptAddress());
        m.put("keyword2", keyword2);
        
        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword3", keyword3);
        
        TemplateData keyword4 = new TemplateData();
        keyword4.setColor("#000000");
        keyword4.setValue(order.getPrice());
        m.put("keyword4", keyword4);
        
        TemplateData keyword5 = new TemplateData();
        keyword5.setColor("#000000");
        keyword5.setValue(order.getOrderNo());
        m.put("keyword5", keyword5);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("请核对信息，如有疑问请联系客服：400-8306-830");
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	
	
	}
	
	/**
	 * 
	 * @Title: sendT7 
	 * @Description: 还款 确认通知
	 * @param order
	 * @param openId 参数说明
	 * @return void    返回类型
	 */
	public static void sendT7(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setUrl(progressUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T7.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("尊敬的六唯壹用户，您已确认珠宝换款，我们会尽快安排发货，敬请留意！");
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue("珠宝换款");
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getOrderNo());
        m.put("keyword2", keyword2);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("请核对信息，如有疑问请联系客服：400-8306-830");
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	
	
	
	}
	
	/**
	 * 用户放弃换款/回收 商家发货通知
	 * @param order
	 * @param openId
	 */
	public static void sendT8(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T8.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        if("005".equals(order.getOrderType())){//换款
        	 temp.setUrl(procPostUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	if(order.isCustomerConfirm()){//确认换款
        		first.setValue("您选择兑换新的珠宝已交付顺丰小哥，请注意查收！");
        	}else{
        		first.setValue("您已确认放弃珠宝换款，货品已交付顺丰小哥，请注意查收！");
        	}
        
        }else if("004".equals(order.getOrderType())){//回收
        	 temp.setUrl(procPostUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        	first.setValue("您已确认放弃产品回收，货品已交付顺丰小哥，请注意查收！");
        }
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(order.getExpressCode());
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getReceiptAddress());
        m.put("keyword2", keyword2);
        
        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword3", keyword3);
        
        TemplateData keyword4 = new TemplateData();
        keyword4.setColor("#000000");
        keyword4.setValue(order.getOrderNo());
        m.put("keyword4", keyword4);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("请核对信息，如有疑问请联系客服：400-8306-830");
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	
	
	
	}
	
	/**
	 * 翻新/维修/检测 取货通知
	 * @param order
	 * @param openId
	 */
	public static void sendT9(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setUrl(progressUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T9.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("您的宝贝".concat(order.getOrderTypeDesc()).concat("服务已完成，请尽快到门店取回您的宝贝！"));
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(order.getStoreAddress());
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getStoreContactName());
        m.put("keyword2", keyword2);
        
        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword3", keyword3);
        
        TemplateData keyword4 = new TemplateData();
        keyword4.setColor("#000000");
        keyword4.setValue(order.getPrice());
        m.put("keyword4", keyword4);
        
        TemplateData keyword5 = new TemplateData();
        keyword5.setColor("#000000");
        keyword5.setValue(order.getOrderNo());
        m.put("keyword5", keyword5);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("请核对信息，如有疑问请联系客服：400-8306-830");
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	
	}
	
	/**
	 * 
	 * @Title: sendT10 
	 * @Description: 翻新/维修/检测/换款/回收 门店收货通知
	 * @param order
	 * @param openId 参数说明
	 * @return void    返回类型
	 */
	public static void sendT10(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setUrl(progressDetailUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T10.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("尊敬的六唯壹用户，您的宝贝我司已收到！查看收货证书请点击");
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getOrderNo());
        m.put("keyword2", keyword2);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("我们下一步将为你的宝贝提供贵金属检测 服务，敬请留意！");
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	}
	
	/**
	 * 
	 * @Title: sendT11 
	 * @Description: 维修 费用通知 
	 * @param order
	 * @param openId 参数说明
	 * @return void    返回类型
	 */
	public static void sendT11(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setUrl(repairFeeUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T11.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("尊敬的六唯壹用户，根据您提交的产品图片与信息，所需维修费用如下：");
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue(order.getPrice());
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword2", keyword2);
        
        TemplateData keyword3 = new TemplateData();
        keyword3.setColor("#000000");
        keyword3.setValue(order.getOrderNo());
        m.put("keyword3", keyword3);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("继续操作请点击");
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	
	}
	
	/**
	 * 
	 * @Title: sendT12 
	 * @Description: 回收确认通知
	 * @param order
	 * @param openId 参数说明
	 * @return void    返回类型
	 */
	public static void sendT12(CommonOrder order){
		String openId = order.getOpenId();
        WXTemplate temp = new WXTemplate();
        temp.setUrl(progressUrl.replace("ORDER_NO", order.getOrderNo()).replace("ORDER_TYPE", order.getOrderType()));
        temp.setTouser(openId);
        temp.setTopcolor("#000000");
        temp.setTemplate_id(WeixinMsgPushEnum.T12.templateId);
        Map<String, TemplateData> m = new HashMap<String, TemplateData>();
        
        TemplateData first = new TemplateData();
        first.setColor("#000000");
        first.setValue("尊敬的六唯壹用户，您已确认产品回收，回收的款项已发放到您的帐户钱包，请注意查收！");
        m.put("first", first);
        
        TemplateData keyword1 = new TemplateData();
        keyword1.setColor("#000000");
        keyword1.setValue("珠宝".concat(order.getOrderTypeDesc()));
        m.put("keyword1", keyword1);
        
        TemplateData keyword2 = new TemplateData();
        keyword2.setColor("#000000");
        keyword2.setValue(order.getOrderNo());
        m.put("keyword2", keyword2);
        
        TemplateData remark = new TemplateData();
        remark.setColor("#000000");
        remark.setValue("如有疑问请联系客服：400-8306-830");
        
        m.put("remark", remark);
        
        temp.setData(m);
        String jsonString = JSONObject.fromObject(temp).toString();
        String url = urlPrefix.concat(AccessTokenUtil.getAccessToken().getAccessToken());
        JSONObject jsonObject = WeiXinUtil.httpsRequset(url, "POST", jsonString);
        System.out.println(jsonObject);
        int result = 0;
        if (null != jsonObject) {
            if (0 != jsonObject.getInt("errcode")) {
                result = jsonObject.getInt("errcode");
            }
        }
        logger.info("模板消息发送结果：" + result);
	
	}
	
	
	public static void main(String[] args) {
		String openId = "okhnkvrNfTI7ZE0-08AcCmK-5cbA";
		String orderNo = "20170617151100008955";
		CommonOrder order = new CommonOrder();
		order.setOrderNo(orderNo);
		order.setExpressCode("5555");
		order.setOrderType("003");
		order.setOrderTypeDesc("回收");
		order.setPrice("0.01");
		order.setReceiptAddress("新安街道39区53栋804");
		order.setStoreAddress("深圳珠宝城4楼");
		order.setStoreContactName("金小六");
		order.setSendWay("002");
		order.setGetWay("001");
		order.setOpenId(openId);
		
		WeixinMsgPushUtil.sendT1(order);
		//util.sendT2(order, openId);
//		util.sendT4(order);
	}

}
